package com.jucai.pppeiyouclient.view.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.jucai.pppeiyouclient.R;
import com.jucai.pppeiyouclient.base.BaseActivity;
import com.jucai.pppeiyouclient.utils.ActivityCollector;
import com.jucai.pppeiyouclient.utils.LogUtils;
import com.jucai.pppeiyouclient.utils.ToastUtils;

public class TextInputActivity extends BaseActivity {
    private EditText inputContent;
    private Button inputSubmit;

    @Override
    protected void initView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_text_input);
        ((TextView) findViewById(R.id.common_title_text)).setText("请输入内容");
        findViewById(R.id.common_home_back).setVisibility(View.INVISIBLE);
        inputContent = (EditText) findViewById(R.id.input_content);
        inputSubmit = (Button) findViewById(R.id.input_submit);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void loadNetData() {

    }

    @Override
    protected void setListener() {
        findViewById(R.id.common_back).setOnClickListener(this);
        inputSubmit.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.common_back:
                ActivityCollector.removeActivity(this);
                break;

            case R.id.input_submit:
                Intent intent = new Intent();
                if (TextUtils.isEmpty(inputContent.getText().toString())) {
                    ToastUtils.showToast("内容不能为空哦~");
                } else {
                    intent.putExtra("data_return", inputContent.getText().toString());
                    LogUtils.e("data ic_back_forward ---> content = " + inputContent.getText().toString());
                    setResult(RESULT_OK, intent);
                    ActivityCollector.removeActivity(this);
                }
                break;
        }
    }
}
